import json
import ssl
# 导入数据请求模块
import requests
# 导入格式化输出模块
from pprint import pprint
# 导入csv
import csv
import urllib3 # 导入urllib3模块
urllib3.disable_warnings() # 关闭ssl警告

# context = ssl.create_default_context()
# context.check_hostname = False
# context.verify_mode = ssl.CERT_NONE

headers = {
    'Cookie': 'guid=34f212fea873ea22519cf4164265786b; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2234f212fea873ea22519cf4164265786b%22%2C%22first_id%22%3A%221900541795925e-0b30abee4d1db58-4c657b58-1327104-1900541795a68f%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTkwMDU0MTc5NTkyNWUtMGIzMGFiZWU0ZDFkYjU4LTRjNjU3YjU4LTEzMjcxMDQtMTkwMDU0MTc5NWE2OGYiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIzNGYyMTJmZWE4NzNlYTIyNTE5Y2Y0MTY0MjY1Nzg2YiJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%2234f212fea873ea22519cf4164265786b%22%7D%2C%22%24device_id%22%3A%221900541795925e-0b30abee4d1db58-4c657b58-1327104-1900541795a68f%22%7D; nsearch=jobarea%3D%26%7C%26ord_field%3D%26%7C%26recentSearch0%3D%26%7C%26recentSearch1%3D%26%7C%26recentSearch2%3D%26%7C%26recentSearch3%3D%26%7C%26recentSearch4%3D%26%7C%26collapse_expansion%3D; Hm_lvt_1370a11171bd6f2d9b1fe98951541941=1718589078; Hm_lpvt_1370a11171bd6f2d9b1fe98951541941=1718590187; acw_sc__v2=666f9bc243a653063725748df58e58b39444fb50; JSESSIONID=F41F7345AC885A280D89DFD537A4F984; search=jobarea%7E%60110300%7C%21recentSearch0%7E%60110300%A1%FB%A1%FA000000%A1%FB%A1%FA0000%A1%FB%A1%FA00%A1%FB%A1%FA99%A1%FB%A1%FA%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA9%A1%FB%A1%FA99%A1%FB%A1%FA%A1%FB%A1%FA0%A1%FB%A1%FAQt%A1%FB%A1%FA2%A1%FB%A1%FA1%7C%21recentSearch1%7E%60000000%A1%FB%A1%FA000000%A1%FB%A1%FA0000%A1%FB%A1%FA00%A1%FB%A1%FA99%A1%FB%A1%FA%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA9%A1%FB%A1%FA99%A1%FB%A1%FA%A1%FB%A1%FA0%A1%FB%A1%FAQt%A1%FB%A1%FA2%A1%FB%A1%FA1%7C%21recentSearch2%7E%60110300%A1%FB%A1%FA000000%A1%FB%A1%FA0000%A1%FB%A1%FA00%A1%FB%A1%FA99%A1%FB%A1%FA%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA99%A1%FB%A1%FA9%A1%FB%A1%FA99%A1%FB%A1%FA%A1%FB%A1%FA0%A1%FB%A1%FA%A1%FB%A1%FA2%A1%FB%A1%FA1%7C%21; acw_tc=ac11000117185936661354388e007faf2f4361fed2ff7eb1ee658dd35585fd; ssxmod_itna=QqAx2DRD0DB7eY5GH5ExCwhxfxtD9iD/Zoh7x0v2IeGzDAxn40iDtoPT0A7fGjcB43Gqjjxe3KhWEwxfQsiEifm+DU4i8DCk0o4bDeW=D5xGoDPxDeDADYo6DAqiOD7qDdEsNv/8DbxYpnDDoDY362DitD4qDBzxdDKqGg7TxD0ThQuCPe4mijiWtYhkD4=0GnD0toxBL=7ahn7jcHaDN4dZnViOQDzLHDtwtgRTdYx0P9nLUVQhDWiBdziGxo9ipxnD44WDmX0BwdBzGxG0DdKAhel0Dzty1oWDDABO8xD=; ssxmod_itna2=QqAx2DRD0DB7eY5GH5ExCwhxfxtD9iD/ZohDn9E4DsvDw24jKG7j3KKqk4D=; tfstk=f-lrO-bhfQdy1Ak30oNUbXDo1yV8g5K6LXZQ-203PuqlNUHViyi7Ve3H2DlUm2c7quT8TJmnqDypykZ3YDgnFEO614389WcefCO1fCEHXbrhAWVywNAyfhO6GqDVsM-sd7GgKozLmz4lZ_Y4nyUTtz2hZEr08PBhqDVHuqqYRaXurubcoza3xXj8xl1478Yin5qon9eaUl02B65ng1wzj4qVthc4znEiro5htuHXXZgqP35tl7hEbPiWi_oZ-VH33XSDbkhqobDnkg-Uaqi-_7cw4_abLukmZ-7htqPumRME43W8qYi4Br2c8CUjfo0-Zx8dm4m_4740hCYZoJDjwRhWm_PiB4NSKcxfFuDa-glhvrYkVXHPx9yukrr6uExfeDqUXgIo_9BLexU4fULRp9eukrr6uEWdp8FTulTJy',
    # 'Referer': 'https://we.51job.com/pc/search?jobArea=010000,020000,030200,040000,090200&keyword=python&searchType=2&sortType=0&metro=',
    'Referer': 'https://we.51job.com/pc/search?keyword=Qt&searchType=2&sortType=0&metro=',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0',
}
# 请求链接
url = 'https://we.51job.com/api/job/search-pc'
# 请求参数
data = {
    'api_key': '51job',
    'timestamp': '1718593650',
    'keyword': 'Qt',
    'searchType': '2',
    'function': '',
    'industry': '',
    # 'jobArea': '010000,020000,030200,040000,090200',
    'jobArea': '110300',
    'jobArea2': '',
    'landmark': '',
    'metro': '',
    'salary': '',
    'workYear': '',
    'degree': '',
    'companyType': '',
    'companySize': '',
    'jobType': '',
    'issueDate': '',
    'sortType': '0',
    'pageNum': '1',
    'requestId': '',
    'pageSize': '20',
    'source': '1',
    'accountId': '',
    'pageCode': 'sou|sou|soulb',
}
# 发送请求
# response = requests.get(url=url, params=data, headers=headers)
http = urllib3.PoolManager() # 创建连接池管理对象
r = http.request('GET', url, headers=headers, json=data) # 发送GET请求


j = json.loads(r.data.decode('unicode_escape')) # 将响应数据转换为字典类型
print(j)
